package cn.yl.caner.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yl.caner.service.CheckService;

public class CheckAccount extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		//ajax请求所到的区域 检查帐号
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		String email = request.getParameter("email");
		String phone = request.getParameter("phone");
		CheckService checkService = new CheckService(); 
		boolean isUsername = false;
		boolean isEmail = false;
		boolean isPhone = false;
			if(username != null) {
				isUsername = checkService.check(username,"username");
				response.getWriter().write("{\"isUsername\":"+isUsername+"}");
			}
			if(email != null) {
				isEmail = checkService.check(email,"email");
				response.getWriter().write("{\"isEmail\":"+isEmail+"}");
			}
			if(phone != null) {
				isPhone = checkService.check(phone,"phone");
				response.getWriter().write("{\"isPhone\":"+isPhone+"}");
			}
		}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}